/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Extras.GestorEstilos;
import Extras.LookAndFeel;
import Gestores.GestorCliente;
import Gestores.GestorServidor;
import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

/**
 *
 * @author Francisco
 */
public class PrincipalF extends javax.swing.JFrame {

    public boolean todoOk;
    private UnirseAPartidaD unirseAPartidaD;

    public PrincipalF() {
        initComponents();
        setLocationRelativeTo(null);
        todoOk = false;
        GestorEstilos.pintar(this);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jB_crearPartida = new javax.swing.JButton();
        jB_unirseAPartida = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Monopoly");
        setMinimumSize(new java.awt.Dimension(424, 91));
        setPreferredSize(new java.awt.Dimension(430, 120));
        setResizable(false);
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("¡Bienvenido a Monopoly!");
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        getContentPane().add(jLabel1);
        jLabel1.setBounds(100, 10, 220, 28);

        jB_crearPartida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Botones/CREARPARTIDA ON.png"))); // NOI18N
        jB_crearPartida.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jB_crearPartida.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_crearPartidaMouseReleased(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jB_crearPartidaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jB_crearPartidaMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_crearPartidaMousePressed(evt);
            }
        });
        jB_crearPartida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_crearPartidaActionPerformed(evt);
            }
        });
        jB_crearPartida.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jB_crearPartidaKeyPressed(evt);
            }
        });
        getContentPane().add(jB_crearPartida);
        jB_crearPartida.setBounds(26, 57, 132, 22);

        jB_unirseAPartida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Botones/UNIRSEAPARTIDA ON.png"))); // NOI18N
        jB_unirseAPartida.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jB_unirseAPartidaMouseReleased(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jB_unirseAPartidaMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jB_unirseAPartidaMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jB_unirseAPartidaMousePressed(evt);
            }
        });
        jB_unirseAPartida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jB_unirseAPartidaActionPerformed(evt);
            }
        });
        jB_unirseAPartida.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jB_unirseAPartidaKeyPressed(evt);
            }
        });
        getContentPane().add(jB_unirseAPartida);
        jB_unirseAPartida.setBounds(270, 57, 132, 22);

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void jB_crearPartidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_crearPartidaActionPerformed
        GestorServidor gestorServidor = new GestorServidor(this);
        gestorServidor.iniciarConexion();
        gestorServidor.crearEnEspera(this);
    }//GEN-LAST:event_jB_crearPartidaActionPerformed

    private void jB_unirseAPartidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaActionPerformed
        GestorCliente gestorCliente = new GestorCliente(this);
        unirseAPartidaD = new UnirseAPartidaD(this, true, gestorCliente);
        unirseAPartidaD.setVisible(true);
    }//GEN-LAST:event_jB_unirseAPartidaActionPerformed

    private void jB_crearPartidaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jB_crearPartidaKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            this.jB_crearPartidaActionPerformed(null);
        }
    }//GEN-LAST:event_jB_crearPartidaKeyPressed

    private void jB_unirseAPartidaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            this.jB_unirseAPartidaActionPerformed(null);
        }
    }//GEN-LAST:event_jB_unirseAPartidaKeyPressed

    private void jB_crearPartidaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_crearPartidaMouseEntered
        jB_crearPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/CREARPARTIDA SEL.png")));
    }//GEN-LAST:event_jB_crearPartidaMouseEntered

    private void jB_crearPartidaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_crearPartidaMouseExited
         jB_crearPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/CREARPARTIDA ON.png")));
    }//GEN-LAST:event_jB_crearPartidaMouseExited

    private void jB_crearPartidaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_crearPartidaMousePressed
         jB_crearPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/CREARPARTIDA OFF.png")));
    }//GEN-LAST:event_jB_crearPartidaMousePressed

    private void jB_crearPartidaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_crearPartidaMouseReleased
         jB_crearPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/CREARPARTIDA ON.png")));
    }//GEN-LAST:event_jB_crearPartidaMouseReleased

    private void jB_unirseAPartidaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaMouseEntered
         jB_unirseAPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/UNIRSEAPARTIDA SEL.png")));
    }//GEN-LAST:event_jB_unirseAPartidaMouseEntered

    private void jB_unirseAPartidaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaMouseExited
        jB_unirseAPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/UNIRSEAPARTIDA ON.png")));
    }//GEN-LAST:event_jB_unirseAPartidaMouseExited

    private void jB_unirseAPartidaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaMousePressed
        jB_unirseAPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/UNIRSEAPARTIDA OFF.png")));
    }//GEN-LAST:event_jB_unirseAPartidaMousePressed

    private void jB_unirseAPartidaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jB_unirseAPartidaMouseReleased
        jB_unirseAPartida.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Botones/UNIRSEAPARTIDA ON.png")));
    }//GEN-LAST:event_jB_unirseAPartidaMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jB_crearPartida;
    private javax.swing.JButton jB_unirseAPartida;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

    public void setTodoOk(boolean estado) {
        todoOk = estado;
    }

    @Override
    public Image getIconImage() {
        Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("Imagenes/icono.png"));
        return retValue;
    }

    @Override
    public List<Image> getIconImages() {
        ArrayList<Image> imageList = new ArrayList();
        imageList.add(Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("Imagenes/iconoTaskBar.png")));
    return imageList;
    }
    
    
}
